<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>阜安街道智慧党建平台</title>
    <meta name="description" content="">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="icon" type="image/png" href="assets/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="assets/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI" />
    <script src="assets/js/echarts.min.js"></script>
    <link rel="stylesheet" href="assets/css/amazeui.min.css" />
    <link rel="stylesheet" href="assets/css/amazeui.datatables.min.css" />
    <link rel="stylesheet" href="assets/css/main.css">
    <link rel="stylesheet" href="ztree/css/zTreeStyle/zTreeStyle2.css" type="text/css">
    <link rel="stylesheet" href="assets/css/app.css">
    <link rel="stylesheet" href="assets/css/amazeui.datetimepicker.css">
    <link rel="stylesheet" href="assets/css/style.css">
    <script src="assets/js/jquery.min.js"></script>
    <script>
        let name = sessionStorage.getItem("username");
        if (name === null) {
            alert("您还未登录，请登录！");
            window.location.href = "login.html";
        }
        let user_id = sessionStorage.getItem("user_id");
    </script>
    <style>
        .am-form-group{
            margin-bottom: 4px;
        }
        @media screen and (min-width: 641px){
            .ke-container{
                width: 670px !important;
            }
        }
        @media screen and (max-width: 641px){
            .ke-container{
                width: auto !important;
            }
        }
        .bg{
            margin: 0;
        }
        
        @media screen and (min-width: 641px){
            .box_lable{
                width: 110px;
            }
        }
        @media screen and (min-width: 641px){
           .min-width {
                width: 400px;
            } 
        }     
    </style>
</head>
<body data-type="index">
<script src="assets/js/theme.js"></script>
<div class="am-g tpl-g">
<!-- 头部 -->
<div id="personSettings"></div>
<header class="main_header">
    <!-- 右侧内容 -->
    <div class="tpl-header-fluid">


        <!-- 其它功能-->
        <div class="am-fr tpl-header-navbar">
            <ul>
                <!-- 欢迎语 -->
                <li class="am-text-sm tpl-header-navbar-welcome">
                    <a href="javascript:;">欢迎你, <span id="name"></span> </a>
                </li>
                <!--个人设置-->
                <li class="am-text-sm" data-am-modal="{target: '#settings'}" onclick="settings()">
                    <a href="javascript:;">
                        <span class="am-icon-user"></span> 个人设置
                    </a>
                </li>

                <!--退出系统-->
                <li class="am-text-sm" onclick="exit()">
                    <a href="javascript:;">
                        <span class="am-icon-sign-out"></span> 退出系统
                    </a>
                </li>
            </ul>
        </div>
    </div>
</header>


    <!-- 内容区域 -->
    <div class="tpl-content-wrapper">
        <div class="am-panel am-panel-default" id="postId">
            <div class="am-panel-bd" style="display: flex;justify-content: flex-start;align-items: center">
        
                <a class="flexMenu" href="user.html">
                    <img src="assets/img/yhgl.png">
                    <p>用户管理</p>
                </a>
                        
                <a class="flexMenu " href="shenfen.html">
                    <img src="assets/img/sfgl.png">
                    <p>角色管理</p>
                </a>
                
                <a class="flexMenu " href="access.html">
                    <img src="assets/img/access.png">
                    <p>权限管理</p>
                </a>
                
                <a class="flexMenu" href="danwei.html" rules="zuz"> 
                    <img src="assets/img/chuque.png">
                    <p>组织机构</p>
                </a>
                    
                <a class="flexMenu menu-bg" href="data_dictionary.html">
                    <img src="assets/img/sjzd.png">
                    <p>积分项管理</p>
                </a>

                <div class="flexMenu" id="backup">
                    <img src="assets/img/backup.png">
                    <p>返回</p>
                </div>
        
            </div>
        
        </div>
        <div class="row-content am-cf">
            <div class="row am-cf bg mflex">
                <div class="min-width am-u-sm-12">
                    <div class="widget">
                        <div class="widget-header am-g" style="padding: 13px 0;text-align: center;">
                        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                            <div class="am-btn-group">
                                <button type="button" class="am-btn am-btn-success am-btn-sm add_lm1 quan_xian" rules="shu_add">添加信息</button>
                                <button type="button" class="am-btn am-btn-sm lm_list am-btn-success quan_xian" rules="shu_lan" data-am-modal="{target: '#my-popup'}" >栏目管理</button>
                            </div>
                        </div>
                    </div>
                    <div class="widget-body">
                        <div class="tip_header">
                            积分类别栏目 
                        </div>
                        <ul id="treeDemo" class="ztree"></ul>
                    </div>
                    </div>
                </div>
                <div class="am-u-sm-12 flex1">
                    <div class="widget am-cf">
                        <div class="widget-body  am-fr" style="padding-left: 0">
                            <div class="am-u-sm-12 am-u-md-12 am-u-lg-4  am-u-lg-offset-6 am-fr">
                                <div class="am-input-group am-input-group-sm tpl-form-border-form cl-p" style="height: 33px;">
                                   <!-- <input type="text" class="am-form-field " placeholder="搜索" id="input">
                                    <span class="am-input-group-btn">
                                        <button class="am-btn  am-btn-default am-btn-success tpl-table-list-field am-icon-search search_type" type="button"></button>
                                    </span> -->
                                </div>
                            </div>
                            <div class="am-u-sm-12 am-scrollable-horizontal" style="margin-top: 30px;">
                                <table width="100%" id="table" class=" am-table-hover am-text-nowrap am-table-bordered am-table-centered am-table am-table-compact am-table-striped tpl-table-black ">
                                    <thead>
                                    <tr>
                                        <th>√</th>
                                        <th>积分名目</th>
                                        <th>分值</th>
                                        <th>状态</th>
                                        <th>编辑</th>
                                    </tr>
                                    </thead>
                                    <tbody  id="show">

                                    <!-- more data -->
                                    </tbody>
                                </table>
                            </div>
                            <div class="am-u-lg-12 am-cf">
                                <div class="am-fl">
                                    <label class="am-fl" style=" margin: 1.5rem 10px;">
                                        <input type="checkbox" name="selectAll" id="checkAll" >
                                        全选
                                    </label>
                                    <button class="am-btn am-btn-sm am-fl detele am-btn-danger quan_xian" rules="shu_del">
                                        删除
                                    </button>
                                    <button class="am-btn am-btn-sm am-btn-success am-fl enable quan_xian" rules="shu_qi">
                                        启用
                                    </button>
                                    <button class="am-btn am-btn-sm am-btn-success am-fl disable quan_xian" rules="shu_jin">
                                        禁用
                                    </button>
                                </div>
                                <div class="am-fr">
                                    <ul class="fenye fenye_zz am-pagination tpl-pagination">
                                        <li class="am-active"><a class="first" href="#">首页</a></li>
                                        <li><a href="#" class="up">上一页</a></li>
                                        <li><a href="#" class="down">下一页</a></li>
                                        <li><a class="last" href="#">末页</a></li>
                                        <li>
                                            <a href="javascript:void(0)" style="border: none;">
                                                页次:<span class="page_c"></span>/<span class="pagenum_c"></span>页 
                                                <span class="strip_c"></span>条/页
                                            </a>
                                        </li>
                                        <li>
                                            <a href="javascript:void(0)" style="padding: 0">
                                                <input class="go_page_c" type="text" value="">
                                            </a>
                                        </li>
                                        <li class="go_page_search">
                                            <a href="#">
                                                GO
                                            </a>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>  
    </div>
</div>
<!-- 模拟弹框alert -->
<div class="am-modal am-modal-alert" tabindex="-1" id="my-alert" style="z-index: 1310">
  <div class="am-modal-dialog">
    <div class="am-modal-bd show_desc">
      
    </div>
    <div class="am-modal-footer">
      <span class="am-modal-btn">确定</span>
    </div>
  </div>
</div>
<!--模态窗口栏目管理-->
<div class="am-modal am-modal-no-btn" tabindex="-1" style="z-index: 1301" id="my-popup">
    <div class="am-modal-dialog" >
        <div class="am-modal-hd newBuild">
      栏目管理<a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>
        x
        <!-- <img style="max-width:40px;" src="assets/img/modalClose.png"> -->
        <!-- &times; -->
    </a>
        </div>
        <div class="am-modal-bd am-g" style="padding: 40px">
            <input type="hidden" id="pname2" value="">
            <input type="hidden" id="pid2" value="">
            <div class="am-fl">
                <ul id="treeDemo1" class="ztree" style="background-color: #cccccc2e; border-radius: 5px;height: 280px;overflow: auto;margin-right: 10px;border: 1px solid #B8C3CC"></ul>
            </div>
            <div class="am-btn-group am-fl">
                <!-- <button type="button" class=" add_lm btn_style" data-am-modal="{target: '#modal2'}">添加</button> -->
                <button type="submit" class="ext_lm btn_style">编辑</button>
                <!-- <button type="submit" class="del_lm btn_style">删除</button> -->
                <button class="btn_style cancel" data-am-modal-close>取消</button>
            </div>

        </div>
    </div>
</div>
<!--模态窗口新增-->
<div class="am-modal am-modal-no-btn" tabindex="-1" id="modal1">
    <div class="am-modal-dialog">
        <div class="am-modal-hd">
            信息填报
            <a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>
                x
                <!-- <img style="max-width:40px;" src="assets/img/modalClose.png"> -->
                <!-- &times; -->
            </a>
        </div>
        <div class="am-modal-bd">
            <form method="post"  enctype="multipart/form-data" class="am-form am-form-horizontal" id="form1">
                <div class="am-cf show_tip ">
                    <div class="am-fl show_1 am-cf">
                        <label class="am-fl"></label>
                        <p class="am-fl">
                            =必填项
                        </p>
                    </div>
                    <div class="am-fl show_2">
                        #=输入数字
                    </div>
                </div>
                <input type="hidden" id="flag_id">
                <div class="am-form-group">
                    <label class="am-u-sm-4 am-u-lg-2 am-form-label box_lable" style="background: #AAC9F2;line-height: 30px;">名称</label>
                    <div class="am-u-sm-8 am-u-lg-9 am-u-end">
                        <input type="text" id="infor_name" class="am-radius" placeholder="">
                    </div>
                </div>
                <div class="am-form-group">
                    <label class="am-u-sm-4 am-u-lg-2 am-form-label box_lable" style="background: #AAC9F2;line-height: 30px;">值</label>
                    <div class="am-u-sm-8 am-u-lg-9 am-u-end">
                        <input type="text" class="am-radius" id="date" placeholder="">
                    </div>
                </div>
                <div class="am-form-group">
                    <label class="am-u-sm-4 am-u-lg-2 am-form-label box_lable" style="background: #AAC9F2;line-height: 30px;">排序</label>
                    <div class="am-u-sm-8 am-u-lg-9 am-u-end">
                        <input type="text" class="am-radius" id="editor_id" placeholder="">
                    </div>
                </div>
                <div class="am-form-group">
                    <label class="am-u-sm-4 am-u-lg-2 am-form-label box_lable" style="background: #AAC9F2;line-height: 30px;">分值</label>
                    <div class="am-u-sm-8 am-u-lg-9 am-u-end">
                        <input type="text" class="am-radius" id="infor_link" placeholder="">
                    </div>
                </div>
                <div class="am-btn-group">
                    <button id="go2" type="button" class="" >确定</button>
                    <button class="" data-am-modal-close>取消</button>
                </div>
            </form>
        </div>
    </div>
</div>
<!--模态窗口新增-->
<div class="am-modal am-modal-no-btn" tabindex="-1" id="modal2" style="z-index: 1302">
    <div class="am-modal-dialog">
        <div class="am-modal-hd">
            栏目

        <a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>
            <!-- <img style="max-width:40px;" src="assets/img/modalClose.png"> -->
            <!-- &times; -->
        </a>
        </div>
        <div class="am-modal-bd">
            <form method="post"  enctype="multipart/form-data" class="am-form am-form-horizontal" id="form3">
                <div class="am-cf show_tip ">
                    <div class="am-fl show_1 am-cf">
                        <label class="am-fl"></label>
                        <p class="am-fl">
                            =必填项
                        </p>
                    </div>
                    <div class="am-fl show_2">
                        #=输入数字
                    </div>
                </div>
                <div class="am-form-group">
                    <label class="am-u-sm-4 am-u-lg-2 am-form-label box_lable" style="background: #AAC9F2;line-height: 30px;">名称</label>
                    <div class="am-u-sm-8 am-u-lg-9 am-u-end">
                        <input type="text" class="name1" class="am-radius" placeholder="">
                    </div>
                </div>
                <div class="am-form-group">
                    <label class="am-u-sm-4 am-u-lg-2 am-form-label box_lable" style="background: #AAC9F2;line-height: 30px;">值</label>
                    <div class="am-u-sm-8 am-u-lg-9 am-u-end">
                        <input type="text" class="am-radius value1" placeholder="">
                    </div>
                </div>
                <div class="am-form-group">
                    <label class="am-u-sm-4 am-u-lg-2 am-form-label box_lable" style="background: #AAC9F2;line-height: 30px;">排序</label>
                    <div class="am-u-sm-8 am-u-lg-9 am-u-end">
                        <input type="text" class="am-radius sort1" placeholder="">
                    </div>
                </div>
                <!-- <div class="am-form-group">
                    <label class="am-u-sm-4 am-u-lg-2 am-form-label box_lable" style="background: #CCDDFF;line-height: 30px;">备注</label>
                    <div class="am-u-sm-8 am-u-lg-9 am-u-end">
                        <input type="text" class="am-radius code1" placeholder="">
                    </div>
                </div> -->
                <input type="hidden" id="idnum" value="">
                <div class="am-btn-group" style="margin-top: 10px;">
                    <button id="go_lm" type="button" class="" >确定</button>
                    <button class="" data-am-modal-close>取消</button>
                </div>
            </form>
        </div>
    </div>
</div>
<!-- 确认提示 -->
<div class="am-modal am-modal-confirm" tabindex="-1" id="my-confirm">
  <div class="am-modal-dialog">
    <div class="am-modal-hd"></div>
    <div class="am-modal-bd">
      确定要删除这条记录吗？
    </div>
    <div class="am-modal-footer">
      <span class="am-modal-btn" data-am-modal-cancel>取消</span>
      <span class="am-modal-btn" data-am-modal-confirm>确定</span>
    </div>
  </div>
</div>
<script src="assets/js/amazeui.min.js"></script>
<script src="assets/js/amazeui.datatables.min.js"></script>
<script src="assets/js/dataTables.responsive.min.js"></script>

<script src="ztree/js/jquery.ztree.all.js"></script>
<script src="assets/js/amazeui.datetimepicker.min.js"></script>
<script>
    $('#datetimepicker1').datetimepicker();
    var zTreeObj;
    var id_lm="";
    var token = sessionStorage.getItem("token");
    // zTree 的数据属性，深入使用请参考 API 文档（zTreeNode 节点数据详解）
    var zNodes = [];
    var zNodes1=[];
    $(function(){
        var pages =1;
        function loadData_list(pageNum){
            $.ajax({
                url: testurl+"/integral/getIntegralList",
                headers: {"Authorization": "Bearer " + token},
                contentType: "application/json",
                type: "post",
                data: JSON.stringify({
                    "id": id_lm,
                    "pageNum": pageNum
                }),
                success:function(data){
                    var data_dictionary =data.obj
                    var data_dictionary = data.obj;
                    console.log(data)
                    ssd = Math.ceil(data.pageTotal/data.pageSize);
                    pages = ssd;
                    var str="";
                   
                    $.each(data_dictionary ,function (index,values) {
          
                        str += " <tr class=\"gradeX\">\n" +
                            "                                        <td>"+"<input name=\"selectAll\" value="+values.ids+" type=\"checkbox\"/>"  +"</td>\n" +
                            "                                        <td>"+values.text_+"</td>\n" +
                            "                                        <td>"+values.remark+"</td>\n" +
                            "                                        <td>"+values.statusName+"</td>\n" +
                            "                                        <td><button class=\"quan_xian2 btnImg60\" rules=\"shu_xiu\" onclick=\"revise(" + values.ids +")\">"+"修改"+"</button></td>\n" +
                            "                                    </tr>"
                    });
                    $("#show").html(str);
                    $(".pagenum_c").html(pages)
                    if (pageNum>=pages) {
                        pageNum=pages
                    }
                    $(".strip_c").html(data.pageSize)
                    $(".page_c").html(pageNum);
              

                }
            })
        }
        var pageNum = 1;
        $(".first").click(function(){
         pageNum =1;
             loadData_list(pageNum);
            $(this).parents("li").addClass("am-active").siblings().removeClass("am-active");
        });
        $(".last").click(function(){
            pageNum = $(".pagenum_c").text().trim()
             loadData_list(pageNum);
            $(this).parents("li").addClass("am-active").siblings().removeClass("am-active");
        });
        $(".up").click(function(){
            pageNum=$(".page_c").text().trim()
            if(pageNum == 1){
                return false;
            } else{
                pageNum--;
                 loadData_list(pageNum);
            }
            $(this).parents("li").addClass("am-active").siblings().removeClass("am-active");
        });
        $(".down").click(function(){
            pageNum=$(".page_c").text().trim()
            if(pageNum == pages){
                return false;
            } else{
                pageNum++;
                 loadData_list(pageNum);
            }
            $(this).parents("li").addClass("am-active").siblings().removeClass("am-active");
        });
        $(".go_page_search").click(function(){
            var pageNum_c=$(".go_page_c").val().trim()
             if (isNaN(pageNum_c)||pageNum_c=="") {
                $(".show_desc").html("只能为数字");
                $('#my-alert').modal({target: '#my-alert'});
                $(".go_page_c").val("")
                return
            }
            loadData_list(pageNum_c);
            $(".go_page_c").val("")
        })
        $(".add_lm1").click(function(){
            //$('#form1')[0].reset()
            $("#flag_id").val("")
            $("#infor_name").val("")
            $("#date").val("")
            $("#infor_link").val("")
            $("#editor_id").val("")
            if (id_lm=="") {
                $(".show_desc").html("选择栏目");
                $('#my-alert').modal({target: '#my-alert'});
                return
            }
       
            $('#modal1').modal('open');
        })
        $(".add_lm2").click(function(){
             id_lm=$("#pid2").val().trim()
             if (id_lm=="") {
                $(".show_desc").html("选择栏目");
                $('#my-alert').modal({target: '#my-alert'});
                return
            }
        
            $('#modal1').modal('open');
            $('#my-popup').modal('close');
        })
        var setting = {
            callback: {
                onClick: zTreeOnClick
            }
        };
        var setting1 = {
            callback: {
                onClick: zTreeOnClick1
            }
        };
        //树节点点击
        function zTreeOnClick(event, treeId, treeNode) {
     
            id_lm=treeNode.id;
            loadData_list(1);    
            let b = authList.split(","); // 将字符串按照","分割，存入数组b.
            console.log(b)
            $.each(b, function (index, value) {
                $(".quan_xian2").each(function () {
                    if ($(this).attr("rules") == value) {
                        $(this).show();
                    }
                })
            })
        }
        //获取点击的name
        function zTreeOnClick1(event, treeId, treeNode) {
            $("#pname2").val(treeNode.name);
            $("#pid2").val(treeNode.id);
        }
        //获取树节点
        function loaddata(){
            $.ajax({
                url: testurl+"/dictionary/getIntegralClassTree",
                type:"post",
                async: false,
                headers: { "Authorization": "Bearer " + token},
                contentType: "application/json",
                data:JSON.stringify({
                    "pageNum":"1",
                    "type":"DIC_TYPE"//必传
                }),
                success: function (data) {
                   zNodes=JSON.parse(data.obj)
                }
            });
            $.fn.zTree.init($("#treeDemo"), setting, zNodes);    
        }
        // $.fn.zTree.init($("#treeDemo"), setting, zNodes);    
        loaddata();
        function loaddata2(){
            $.ajax({
                url: testurl+"/dictionary/getIntegralClassTree",
                type:"post",
                async: false,
                headers: { "Authorization": "Bearer " + token},
                contentType: "application/json",
                data:JSON.stringify({
                }),
                success: function (data) {
                    zNodes1=JSON.parse(data.obj)
               
                }
            });
            $.fn.zTree.init($("#treeDemo1"), setting1, zNodes1);
        }
        //点击栏目管理获取节点信息
        $(".lm_list").click(function(){
            loaddata2()
            $("#pname2").val("")
            $("#pid2").val("")
        })
        $(".add_lm").click(function(){
            $('#my-popup').modal('close');
            $('.name1').val("")
            $(".code1").val("")
            $('.value1').val("")
            $(".sort1").val("")
            $("#idnum").val("")
        })
        // 添加修改栏目
        $("#go_lm").click(function(){
            var id=$('#idnum').val()
            var name1=$(".name1").val().trim()
            //var code1=$(".code1").val().trim()
            var value1=$(".value1").val().trim()
            var sort1=$(".sort1").val().trim()
            // var state1=$(".state1").val().trim()
            if (name1=="") {
                $(".show_desc").html("名称不能为空");
                $('#my-alert').modal({target: '#my-alert'});
                return;
            }
            if (value1=="") {
                $(".show_desc").html("值不能为空");
                $('#my-alert').modal({target: '#my-alert'});
                return;
            }
            if (sort1=="") {
                $(".show_desc").html("不能为空");
                $('#my-alert').modal({target: '#my-alert'});
                return;
            }
            if(isNaN(sort1)){
                $(".show_desc").html("只能为数字");
                $('#my-alert').modal({target: '#my-alert'});
                return;
            }
            if (!id=="") {
                $.ajax({
                url: testurl+"/dictionary/update",
                type:"post",
                async: false,
                headers: { "Authorization": "Bearer " + token},

                contentType: "application/json",
                data:JSON.stringify({
                   // "type":"dic_type",
                    "id":id,
                    "text_":name1,
                    "value_":value1,
                    "sort":sort1,
                    //"remark":code1
                }),
                success: function (data) {
                    if (data.success == true) {
                        $(".show_desc").html(data.message);
                        $('#my-alert').modal({target: '#my-alert'});
                        $('#modal2').modal('close');
                        loaddata()
                    }
                    else{
                        $(".show_desc").html(data.message);
                        $('#my-alert').modal({target: '#my-alert'});
                        $('#modal2').modal('close');
                    }
                }
            });
            }
            else{
                $.ajax({
                url: testurl+"/dictionary/",
                type:"post",
                async: false,
                headers: { "Authorization": "Bearer " + token},
                contentType: "application/json",
                data:JSON.stringify({
                    "type":"dic_type",
                    "text_":name1,
                    "value_":value1,
                    "sort":sort1,
                    //"remark":code1
                }),
                success: function (data) {
                    if (data.success == true) {
                        $(".show_desc").html(data.message);
                        $('#my-alert').modal({target: '#my-alert'});
                        $('#modal2').modal('close');
                        loaddata()
                    }
                    else{
                        $(".show_desc").html(data.message);
                        $('#my-alert').modal({target: '#my-alert'});
                        $('#modal2').modal('close');
                    }
                }
            });
            }   
        })
        // 删除栏目
        $(".del_lm").click(function(){
            var id=$("#pid2").val().trim()
            id=id.split(",")
            if (id=="") {
                $(".show_desc").html("请选择要操作的栏目");
                $('#my-alert').modal({target: '#my-alert'});
                return
            }
            $.ajax({
                url: testurl+"/dictionary/deletes",
                type:"post",
                async: false,
                headers: { "Authorization": "Bearer " + token},
                contentType: "application/json",
                data:JSON.stringify({
                    "ids":id
                }),
                success: function (data) {
                    console.log(data)
                    if (data.success == true) {
                        $(".show_desc").html(data.message);
                        $('#my-alert').modal({target: '#my-alert'});
                        loaddata()
                        loaddata2()
                    }
                    else{
                        $(".show_desc").html(data.message);
                        $('#my-alert').modal({target: '#my-alert'});
                    }
                }
            });
        })
        //编辑
        $(".ext_lm").click(function(){
            $('.name1').val("")
            $(".code1").val("")
            $('.value1').val("")
            $(".sort1").val("")
            $("#idnum").val("")
            var id=$("#pid2").val().trim()
            if (id=="") {
                $(".show_desc").html("请选择要操作的栏目");
                $('#my-alert').modal({target: '#my-alert'});
                return
            }
            $.ajax({
                url: testurl+"/dictionary/detail",
                type:"post",
                async: false,
                headers: { "Authorization": "Bearer " + token},
                contentType: "application/json",
                data:JSON.stringify({
                    "id":id
                }),
                success: function (data) {
                    $('#my-popup').modal('close');
                    $('#modal2').modal({target: '#modal2'});
                    var desc=data.obj
                    console.log(desc)
                    $('.name1').val(desc.text_)
                    $('.value1').val(desc.value)
                    $('.sort1').val(desc.sort)
                    $('.code1').val(desc.remark)
                    $('#idnum').val(desc.id)
                    $("#pname2").val("")
                    $("#pid2").val("")
                }
            });
        })
        //修改
        revise=function(e){
            $('#infor_name').val("")
            $("#date").val("")
            $('#editor_id').val("")
            $("#infor_link").val("")
            $("#flag_id").val("")
            $.ajax({
                url: testurl+"/dictionary/detail",
                type:"POST",
                async: false,
                headers: { "Authorization": "Bearer " + token},
                contentType: "application/json",
                data:JSON.stringify({
                    "id":e
                }),
                success: function (data) {
                    $('#modal1').modal({target: '#modal1'});
                    var desc=data.obj
                    console.log(desc)
                    $('#infor_name').val(desc.text_)
                    $('#date').val(desc.value)
                    $('#editor_id').val(desc.sort)
                    $('#infor_link').val(desc.remark)
                    $("#flag_id").val(desc.id)
                }
            });  
        }
        //信息填报
        $("#go2").click(function(){
            var flag_id= $("#flag_id").val()
            let title = $("#infor_name").val().trim();
            let pub_time = $("#date").val().trim();
            let content = $("#editor_id").val().trim();
            let out_link=$("#infor_link").val().trim();
             if (title=="") {
                $(".show_desc").html("名称不能为空");
                $('#my-alert').modal({target: '#my-alert'});
                return;
            }
            if (pub_time=="") {
                $(".show_desc").html("值不能为空");
                $('#my-alert').modal({target: '#my-alert'});
                return;
            }
            if (content=="") {
                $(".show_desc").html("不能为空");
                $('#my-alert').modal({target: '#my-alert'});
                return;
            }
            if(isNaN(content)){
                $(".show_desc").html("排序只能为数字");
                $('#my-alert').modal({target: '#my-alert'});
                return;
            }
            let str = { 
                "pid":id_lm,
                "type":"INTEGRAL_LIST",
                "text_":title,
                "value":pub_time,
                "sort":content,
                "remark":out_link
            };
            if (flag_id=="") {
                $.ajax({
                    async: false,
                    headers: { "Authorization": "Bearer " + token},
                    type: "post",
                    url: testurl+"/dictionary/add",
                    contentType: "application/json",
                    data:JSON.stringify(str),
                    success:function (data) {
                        if (data.success==true) {
                            location.reload();
                            //loadData_list(1)
                            //$('#modal1').modal('close');
                        }
                        else{
                            $(".show_desc").html(data.message);
                            $('#my-alert').modal({target: '#my-alert'});
                            return false;
                        } 
                    }
                });
            }
            else{
                $.ajax({
                    url: testurl+"/dictionary/update",
                    type:"post",
                    async: false,
                    headers: { "Authorization": "Bearer " + token},
                    contentType: "application/json",
                    data:JSON.stringify({ 
                        "id":flag_id,
                        "type":id_lm,
                        "text_":title,
                        "value_":pub_time,
                        "sort":content,
                        "remark":out_link
                    }),
                    success:function (data) {
                        if (data.success==true) {
                            location.reload();
                            //loadData_list(1)
                            //$('#modal1').modal('close');
                        }
                        else{
                            $(".show_desc").html(data.message);
                            $('#my-alert').modal({target: '#my-alert'});
                            return false;
                        } 
                    }
                });
            }
        })
        //删除信息
        $(".detele").click(function () {
            //选中
            var checkedLength = "";
            var deletelid = [];
            var ck=document.getElementsByName("selectAll");
            //得到一组checkbox  相当于数组
            //循环这一组checkbox让每一个checkbox选中
            for(var i=0;i<ck.length;i++){
                if(ck[i].checked==true){//委员选中
                    deletelid.push(ck[i].value);
                    checkedLength=deletelid.length
                }
            }
        
            if (checkedLength <= 0){
                $(".show_desc").html("选择要删除的内容");
                $('#my-alert').modal({target: '#my-alert'});
                return false;
            }else {
                $('#my-confirm').modal({
                    onConfirm: function(options) {
                       $.ajax({
                           type:"post",
                           url: testurl+"/dictionary/enables",
                           contentType:"application/json",
                           headers: { "Authorization": "Bearer " + token},
                           data:JSON.stringify({
                               "ids":deletelid,
                               "status":"0"
                               //"item_id":id_lm
                           }),
                           success: function (data) {
                  
                               $('#checkAll[name="selectAll"]').removeAttr("checked",false);
                               if (data.success == true) {
                                    $(".show_desc").html(data.message);
                                    $('#my-alert').modal({target: '#my-alert'});
                                   loadData_list(1);
                               }else {
                                    $(".show_desc").html(data.message);
                                    $('#my-alert').modal({target: '#my-alert'});
                                   loadData_list(1);
                               }
                           },
                           error:function (data) {
                                $(".show_desc").html(data.message);
                                $('#my-alert').modal({target: '#my-alert'});
                           }
                       });
                    },
                    // closeOnConfirm: false,
                    onCancel: function() {
                      
                    }
                });
               
           }
        }); 
         //启用
        $(".enable").click(function () {
            //选中
            var checkedLength = "";
            var deletelid = [];
            var ck=document.getElementsByName("selectAll");
            //得到一组checkbox  相当于数组
            //循环这一组checkbox让每一个checkbox选中
            for(var i=0;i<ck.length;i++){
                if(ck[i].checked==true){//委员选中
                    deletelid.push(ck[i].value);
                    checkedLength=deletelid.length
                }
            }
     
            if (checkedLength <= 0){
                $(".show_desc").html("选择要启用的信息");
                $('#my-alert').modal({target: '#my-alert'});
                return false;
            }else {
                $.ajax({
                    type:"post",
                    url: testurl+"/dictionary/enables",
                    contentType:"application/json",
                    headers: { "Authorization": "Bearer " + token},
                    data:JSON.stringify({
                        "ids":deletelid,
                        "status":"1"
                    }),
                    success: function (data) {
                        $('#checkAll[name="selectAll"]').removeAttr("checked",false);
                        if (data.success == true) {
                            $(".show_desc").html(data.message);
                            $('#my-alert').modal({target: '#my-alert'});
                            loadData_list(1);
                        }else {
                            $(".show_desc").html(data.message);
                            $('#my-alert').modal({target: '#my-alert'});
                            loadData_list(1);
                        }
                    },
                    error:function (data) {
                        $(".show_desc").html(data.message);
                        $('#my-alert').modal({target: '#my-alert'});
                    }
                });
            }
        });
        //禁用
        $(".disable").click(function () {
            //选中
            var checkedLength = "";
            var deletelid = [];
            var ck=document.getElementsByName("selectAll");
            //得到一组checkbox  相当于数组
            //循环这一组checkbox让每一个checkbox选中
            for(var i=0;i<ck.length;i++){
                if(ck[i].checked==true){//委员选中
                    deletelid.push(ck[i].value);
                    checkedLength=deletelid.length
                }
            }
           
            if (checkedLength <= 0){
                $(".show_desc").html("选择要禁用的信息");
                $('#my-alert').modal({target: '#my-alert'});
                return false;
            }else {
                $.ajax({
                    type:"post",
                    url: testurl+ "/dictionary/enables",
                    contentType:"application/json",
                    headers: { "Authorization": "Bearer " + token},
                    data:JSON.stringify({
                        "ids":deletelid,
                        "status":"2"
                    }),
                    success: function (data) {
                        $('#checkAll[name="selectAll"]').removeAttr("checked",false);
                        if (data.success == true) {
                            $(".show_desc").html(data.message);
                            $('#my-alert').modal({target: '#my-alert'});
                            loadData_list(1);
                        }else {
                            $(".show_desc").html(data.message);
                            $('#my-alert').modal({target: '#my-alert'});
                            loadData_list(1);
                        }
                    },
                    error:function (data) {
                        console.log(data)
                    }
                });
            }
        });
        //选中所有的checkbox框
        $('#checkAll[name="selectAll"]').click(function(){
            if($(this).is(':checked')){
                //var deletelid1=[]
                $('#show input[name="selectAll"]').each(function(i){
                    //此处如果用attr，会出现第三次失效的情况
                    $(this).prop("checked",true);
           
                });
            }else{
                $('input[name="selectAll"]').each(function(){
                    $(this).removeAttr("checked",false);
                
                });
            }
        });
    })
</script>
<script src="assets/js/app.js"></script>
</body>
</html>